﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ivony.Data;
using System.Security.Principal;

namespace XCommunity.Data
{
  internal class ProfilerDataProvider
  {

    public readonly static SqlDbUtility DbUtility = new SqlDbUtility( @"Data Source=(local);Initial Catalog=XCommunity;Integrated Security=True" );

    public int[] GetAttachedTopics( IIdentity account )
    {
      return DbUtility.ExecuteSingleColumn<int>( "SELECT DISTINCT TopicID FROM PublishedDocuments INNER JOIN Documents ON ( PublishedDocuments.DocumentId = Documents.ID ) WHERE Documents.Author = {0} AND PublishMethod IN ( {...} )", account.Name, "AttachTopic", "LaunchTopic" );
    }

    public int[] GetLaunchedTopics( IIdentity account )
    {
      return DbUtility.ExecuteSingleColumn<int>( "SELECT DISTINCT TopicID FROM PublishedDocuments INNER JOIN Documents ON ( PublishedDocuments.DocumentId = Documents.ID ) WHERE Documents.Author = {0} AND PublishMethod IN ( {...} )", account.Name, "LaunchTopic" );
    }

  }
}
